import axios from 'axios'
import config from '../config'

export function create (entity) {
  return axios.post(config.SERVER_URL + window.apiPath + '/duty-descriptions', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}
export function update (entity) {
  return axios.put(config.SERVER_URL + window.apiPath + '/duty-descriptions', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}
export function deleteById (id) {
  return axios.delete(config.SERVER_URL + window.apiPath + '/duty-descriptions/' + id, {responseType: 'json'})
    .then(resp => resp.data)
}
export function search (page, query = '') {
  return axios.get(config.SERVER_URL + window.apiPath + `/duty-descriptions-ps?page=${page}&size=${config.PAGE_SIZE}&query=${query}`, {responseType: 'json'})
    .then(resp => resp)
}
export function searchAll (page, query = '') {
  return axios.get(config.SERVER_URL + window.apiPath + `/duty-descriptions?page=${page}&size=${config.PAGE_SIZE}&query=${query}`, {responseType: 'json'})
  // return axios.get(config.SERVER_URL + window.apiPath + `/duty-descriptions`, {params: params}, {responseType: 'json'})
    .then(resp => resp)
}
export function searchById (id) {
  return axios.get(config.SERVER_URL + window.apiPath + '/duty-descriptions/' + id, {responseType: 'json'})
    .then(resp => resp.data)
}
